package com.yupi.usercenter.rabbitmq;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @author: 王博
 * @create: 2024-04-12 16:58
 */
@Slf4j
@Component
public class CustomerAutoDistributionTimeoutReceiver {



    /*@RabbitListener(bindings = {@QueueBinding(
            value = @Queue(value = "wangbotestqueue",durable = "true"),
            exchange = @Exchange(name = "wangbotestexchange", type = "x-delayed-message", arguments = {@Argument(name = "x-delayed-type", value = ExchangeTypes.DIRECT)})
    )})
    @RabbitHandler
    @Transactional(rollbackFor = Exception.class)
    public void onMessage(@Payload CustomerAutoUnassignMessage customerAutoUnassignMessage, Message message, Channel channel) throws IOException{
        try{
            String customerSn = customerAutoUnassignMessage.getCustomerSn();
            System.out.println(customerSn);
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
            System.out.println("[新客户、二次咨询公海客户分配后超过指定时间未跟进]客户{}存在超期未跟进,被自动收回原有公海"+ customerSn);
        } catch (IOException e) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
            System.out.println("[新客户、二次咨询公海客户分配后超过指定时间未跟进]客户{}存在超期未跟进,被自动收回原有公海，异常了"+e);
        }
    }*/
}
